# 费马小定理 若p为质数，对于任意整数a，都有a^p≡a (mod p)
n = int(input())
s = '0' + input()
mod = int(1e9) + 7

dp = [0] * (n+1)
cnt = 0  # 计数器，用于跟踪连续'1'的数量
inv2 = pow(2, mod-2, mod)
for i in range(1, n+1):
    if s[i] == '0':
        dp[i] = dp[i-1]
        cnt = 0
    elif s[i] == '1':
        dp[i] = (dp[i-1] + (2*cnt+1)) % mod
        cnt += 1
    else:
        dp[i] = (dp[i-1] + (2*cnt+1) * inv2 % mod) % mod
        cnt = (cnt + 1) * inv2 % mod
print(dp[n])
